<!-- 报表管理 -->
<template>
  <div class="">
    <el-card>
      <el-row style="margin-bottom: 5px">
        <el-col :span="24">
          <el-button type="primary" @click="addReport" size="mini" v-has="'add'"
            >添加报表</el-button
          >
        </el-col>
      </el-row>
      <yg-table
        :columns="columns"
        :tableList="TableList"
        :loading="timeListloading"
        :key="Key"
      >
        <el-table-column slot="action" fixed="right" label="操作" width="250">
          <template slot-scope="scope">
            <el-tooltip content="编辑" placement="top" effect="light">
              <el-button
                type="primary"
                icon="el-icon-edit"
                circle
                @click="editReport(scope.row)"
                size="mini"
                v-has="'edit'"
              >
              </el-button>
            </el-tooltip>
            <el-tooltip content="配置表头" placement="top" effect="light">
              <el-button
                type="success"
                icon="el-icon-info"
                circle
                @click="ConfigHear(scope.row)"
                size="mini"
                v-has="'datacfg'"
              >
              </el-button>
            </el-tooltip>
            <el-tooltip content="导出数据配置" placement="top" effect="light">
              <el-button
                type="primary"
                icon="el-icon-download"
                circle
                @click="exprotDataConfig(scope.row)"
                size="mini"
                v-has="'view'"
              ></el-button>
            </el-tooltip>
            <el-tooltip content="导入数据配置" placement="top" effect="light">
              <b style="display: inline-block; margin: 0px 10px">
                <el-upload
                  action
                  ref="upload"
                  accept=".xlsx, .xls"
                  :show-file-list="false"
                  :on-change="
                    (file, fileList) => {
                      handleChange(file, fileList, scope.row);
                    }
                  "
                  :auto-upload="false"
                >
                  <el-button
                    type="primary"
                    size="mini"
                    circle
                    icon="el-icon-upload2"
                  ></el-button>
                </el-upload>
              </b>
            </el-tooltip>
            <el-tooltip content="预览" placement="top" effect="light">
              <el-button
                type="warning"
                icon="el-icon-view"
                circle
                @click="Perview(scope.row)"
                size="mini"
                v-has="'view'"
              ></el-button>
            </el-tooltip>
            <el-tooltip content="删除" placement="top" effect="light">
              <el-button
                type="danger"
                icon="el-icon-delete"
                circle
                @click="delectReport(scope.row)"
                size="mini"
                v-has="'del'"
              >
              </el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </yg-table>
    </el-card>
    <!-- 添加报表弹窗 -->
    <el-dialog
      title="添加报表"
      :visible.sync="addReportDialogVisible"
      width="50%"
      @close="addReportDialogClose"
      :close-on-click-modal="false"
    >
      <yg-from
        ref="addReportForm"
        :formObj="addReportFromObj"
        :formData="addReportFromData"
      ></yg-from>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="addReportDialogVisible = false"
          >取 消</el-button
        >
        <el-button size="mini" type="primary" @click="addReportConfirm"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 修改报表信息 -->
    <el-dialog
      title="修改报表"
      :visible.sync="editReportDialogVisible"
      width="50%"
      :close-on-click-modal="false"
    >
      <yg-from
        ref="editReportForm"
        :formObj="editReportFromObj"
        :formData="editReportFromData"
      ></yg-from>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="editReportDialogVisible = false"
          >取 消</el-button
        >
        <el-button size="mini" type="primary" @click="editReportConfirm"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 读回数据配置信息 -->
    <el-dialog
      class="tablehead-dialog"
      title="配置表头"
      :visible.sync="ConfigHearDialogVisible"
      width="50%"
      @close="ConfigHearDialogClose"
      :close-on-click-modal="false"
    >
      <el-row>
        <el-col :span="24">
          <el-button type="primary" @click="addHead" size="mini"
            >添加</el-button
          >
        </el-col>
      </el-row>
      <yg-table :columns="dialogColumns" :tableList="dataList">
        <el-table-column slot="actio" fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <el-button
              type="primary"
              icon="el-icon-edit"
              @click="editRow(scope.$index, scope.row, dataList)"
              size="mini"
            ></el-button>
            <el-button
              type="danger"
              icon="el-icon-delete"
              @click="deleteRow(scope.$index, dataList)"
              size="mini"
            >
            </el-button>
          </template>
        </el-table-column>
      </yg-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="ConfigHearDialogVisible = false"
          >取 消</el-button
        >
        <el-button size="mini" type="primary" @click="ConfigHearOk"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 配置列信息 -->
    <!-- 添加表头 -->
    <el-dialog
      title="添加表头"
      :visible.sync="addHaedDialogVisible"
      append-to-body
      width="50%"
      :close-on-click-modal="false"
      @close="addHaedDialogClose"
    >
      <yg-from
        ref="addHaedRef"
        :formObj="addHaedObj"
        :formData="addHaedData"
      ></yg-from>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="addHaedDialogVisible = false"
          >取 消</el-button
        >
        <el-button size="mini" type="primary" @click="addHaedOk"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      title="编辑表头"
      :visible.sync="editHaedDialogVisible"
      append-to-body
      width="50%"
      :close-on-click-modal="false"
      @close="editHaedDialogClose"
    >
      <yg-from
        ref="editHaedRef"
        :formObj="editHaedObj"
        :formData="editHaedData"
      ></yg-from>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="editHaedDialogVisible = false"
          >取 消</el-button
        >
        <el-button size="mini" type="primary" @click="editHaedOk"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 预览数据 -->
    <el-dialog
      title="预览数据"
      :visible.sync="previewDialogVisible"
      width="80%"
      :close-on-click-modal="false"
      @close="previewDataDialogClose"
    >
      <el-row type="flex">
        <el-col :span="20"><div></div></el-col>
        <el-col :span="4"
          ><div style="float: right; margin-top: -5px">
            <el-button
              type="primary"
              icon="el-icon-download"
              size="mini"
              @click="exportButton"
              >导出</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-printer"
              size="mini"
              @click="printJson"
              >打印</el-button
            >
          </div></el-col
        >
      </el-row>
      <ux-grid
        :key="Key"
        class="tableListValue"
        :data="body"
        ref="plxTable"
        id="myTable"
        stripe
        border
        :max-height="'300'"
        size="mini"
        :header-cell-style="{ 'text-align': 'center', width: '100%' }"
        style="width: 100%; font-size: 12px"
        v-loading="loadingShow"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        :highlight-current-row="true"
        show-overflow="tooltip"
        widthResize
      >
        <ux-table-column
          v-for="(item, index) in header"
          :key="index"
          :width="item.width"
          :title="index == 0 ? '' : item.name"
          :field="'header.' + index + '.value'"
          :align="item.alian"
        >
          <template slot-scope="scope">
            {{ scope.row[index] }}
          </template>
        </ux-table-column>
      </ux-grid>
    </el-dialog>
  </div>
</template>

<script>
import {
  dataURLtoBlob,
  getBase64,
  exportExcel,
} from "@/utils/exportExcelBlob/index";
import YgTable from "@/components/Table/YgTable.vue";
import YgFrom from "@/components/Form/YgFrom.vue";
import {
  setMessageCallback,
  publishMsg,
  removeMessageCallback,
  checkSpecialId,
} from "@/mqtt";
export default {
  name: "ParamReport",
  components: {
    YgTable,
    YgFrom,
  },
  data() {
    //这里存放数据
    return {
      timeListloading: false,
      addReportDialogVisible: false, //添加报表弹窗显隐
      editReportDialogVisible: false, //修改报表信息
      ConfigHearDialogVisible: false, //配置表头
      addHaedDialogVisible: false, //添加表头
      editHaedDialogVisible: false, //编辑表头
      addDataEchoDialogVisible: false, //添加数据配置回显
      previewDialogVisible: false, //预览数据
      loadingShow: false, //加载表格数据
      columns: [
        {
          prop: "id",
          label: "数据id",
          align: "left",
        },
        {
          prop: "name",
          label: "名称",
          align: "left",
        },
        {
          prop: "update_time",
          label: "最后保存时间",
        },
        { slot: "action" },
      ],
      dialogColumns: [
        {
          index: true,
        },
        {
          prop: "name",
          label: "名称",
        },
        {
          prop: "unit",
          label: "单位",
        },
        {
          prop: "width",
          label: "宽度",
        },
        {
          prop: "alian",
          label: "靠齐",
          formatter(row) {
            if (row.hasOwnProperty("alian")) {
              if (row.alian == "center") {
                return "居中";
              }
              if (row.alian == "left") {
                return "居左";
              }
              if (row.alian == "right") {
                return "居右";
              }
            } else {
              return "";
            }
          },
        },
        {
          prop: "type",
          label: "数据类型",
          formatter(row) {
            if (row.hasOwnProperty("type")) {
              if (row.type == "yc") {
                return "遥测";
              }
              if (row.type == "yx") {
                return "遥信";
              }
              if (row.type == "ym") {
                return "遥脉";
              }
              if (row.type == "task") {
                return "定时任务";
              }
            } else {
              return "";
            }
          },
        },
        { slot: "actio" },
      ],
      TableList: [],
      addReportFromObj: [
        {
          input: true, //是input
          label: "数据ID", //字段
          prop: "id", //字段名
          width: 12, //参考el-col
          placeholder: "请输入数据ID",
          disabled: false, //是否禁用
          labelWidth: "80px",
          rules: [
            {
              required: true,
              message: "请输入数据ID",
            },
          ],
        },
        {
          input: true, //是input
          label: "名称", //字段
          prop: "name", //字段名
          width: 12, //参考el-col
          placeholder: "请输入名称",
          disabled: false, //是否禁用
          labelWidth: "80px",
        },
        {
          select: true, //是input
          label: "报表类型", //字段
          prop: "type", //字段名
          width: 12, //参考el-col
          placeholder: "请输入报表类型",
          disabled: false, //是否禁用
          labelWidth: "80px",
          options: [
            { label: "普通实时报表", value: 0 },
            { label: "告警实时报表", value: 1 },
          ],
        },
      ],
      addReportFromData: {
        id: "",
        name: "",
        type: 0,
      },
      editReportFromObj: [
        {
          input: true, //是input
          label: "数据ID", //字段
          prop: "id", //字段名
          width: 12, //参考el-col
          placeholder: "请输入数据ID",
          disabled: true, //是否禁用
          labelWidth: "80px",
        },
        {
          input: true, //是input
          label: "名称", //字段
          prop: "name", //字段名
          width: 12, //参考el-col
          placeholder: "请输入名称",
          disabled: false, //是否禁用
          labelWidth: "80px",
        },
        {
          select: true, //是input
          label: "报表类型", //字段
          prop: "type", //字段名
          width: 12, //参考el-col
          placeholder: "请输入报表类型",
          disabled: false, //是否禁用
          labelWidth: "80px",
          options: [
            { label: "普通实时报表", value: 0 },
            { label: "告警实时报表", value: 1 },
          ],
        },
      ],
      editReportFromData: {
        id: "",
        name: "",
        type: "",
      },
      addHaedObj: [
        {
          input: true, //是input
          label: "名称", //字段
          prop: "name", //字段名
          width: 5, //参考el-col
          placeholder: "请输入名称",
          disabled: false, //是否禁用
          labelWidth: "60px",
          rules: [
            {
              required: true,
              message: "请输入名称",
            },
          ],
        },
        {
          input: true, //是input
          label: "单位", //字段
          prop: "unit", //字段名
          width: 5, //参考el-col
          placeholder: "请输入单位",
          disabled: false, //是否禁用
          labelWidth: "40px",
        },
        {
          input: true, //是input
          label: "宽度(px)", //字段
          prop: "width", //字段名
          width: 5, //参考el-col
          placeholder: "请输入宽度",
          disabled: false, //是否禁用
          labelWidth: "80px",
        },
        {
          select: true,
          label: "靠齐", //字段
          prop: "alian", //字段名
          placeholder: "请选择对齐方式", //提示内容
          width: 4, //参考el-col
          disabled: false, //是否禁用
          clearable: false, //是否清空
          labelWidth: "40px",
          options: [
            { label: "居中", value: "center" },
            { label: "居左", value: "left" },
            { label: "居右", value: "right" },
          ],
        },
        {
          select: true,
          label: "数据类型", //字段
          prop: "type", //字段名
          placeholder: "请选择数据类型", //提示内容
          width: 5, //参考el-col
          disabled: false, //是否禁用
          clearable: true, //是否清空
          labelWidth: "80px",
          options: [
            { label: "遥信", value: "yx" },
            { label: "遥测", value: "yc" },
            { label: "遥调", value: "ym" },
            { label: "定时任务", value: "task" },
          ],
        },
      ],
      addHaedData: {
        name: "",
        alian: "",
        unit: "",
        type: "",
        width: "",
      },
      editHaedObj: [
        {
          input: true, //是input
          label: "名称", //字段
          prop: "name", //字段名
          width: 5, //参考el-col
          placeholder: "请输入名称",
          disabled: false, //是否禁用
          labelWidth: "60px",
          rules: [
            {
              required: true,
              message: "请输入名称",
            },
          ],
        },
        {
          input: true, //是input
          label: "单位", //字段
          prop: "unit", //字段名
          width: 5, //参考el-col
          placeholder: "请输入单位",
          disabled: false, //是否禁用
          labelWidth: "40px",
        },
        {
          input: true, //是input
          label: "宽度(px)", //字段
          prop: "width", //字段名
          width: 5, //参考el-col
          placeholder: "请输入宽度",
          disabled: false, //是否禁用
          labelWidth: "80px",
        },
        {
          select: true,
          label: "靠齐", //字段
          prop: "alian", //字段名
          placeholder: "请选择对齐方式", //提示内容
          width: 4, //参考el-col
          disabled: false, //是否禁用
          clearable: false, //是否清空
          labelWidth: "40px",
          options: [
            { label: "居中", value: "center" },
            { label: "居左", value: "left" },
            { label: "居右", value: "right" },
          ],
        },
        {
          select: true,
          label: "数据类型", //字段
          prop: "type", //字段名
          placeholder: "请选择数据类型", //提示内容
          width: 5, //参考el-col
          disabled: false, //是否禁用
          clearable: true, //是否清空
          labelWidth: "80px",
          options: [
            { label: "遥信", value: "yx" },
            { label: "遥测", value: "yc" },
            { label: "遥调", value: "ym" },
            { label: "定时任务", value: "task" },
          ],
        },
      ],
      editHaedData: {
        name: "",
        alian: "",
        unit: "",
        type: "",
        width: "",
      },
      addcolsData: {
        colsList: [
          {
            value: "",
          },
        ],
      },
      tableColsList: [],
      dataList: [],
      dataIndex: "",
      body: [],
      header: [],
      bodyConfigList: [],
      getBodyData: false,
      Key: 0,
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    initTableKey() {
      this.Key = 1000 + Math.trunc(Math.random() * 1000);
    },
    renderheader(h, { column, $index }) {
      return h("div", {}, [
        h("div", {}, column.label.split(",")[0]),
        h("div", {}, column.label.split(",")[1]),
      ]);
    },
    addReport() {
      this.addReportDialogVisible = true;
    },
    editReport(val) {
      console.log("修改报表信息", val);
      this.editReportDialogVisible = true;
      this.editReportFromData.id = val.id;
      this.editReportFromData.name = val.name;
      this.editReportFromData.type = Number(val.type);
    },
    //编辑数据配置里面的表格
    editRow(val, row, data) {
      this.editHaedDialogVisible = true;
      this.dataIndex = val;
      this.editHaedData.name = row.name;
      this.editHaedData.unit = row.unit;
      this.editHaedData.type = row.type;
      this.editHaedData.alian = row.alian;
      this.editHaedData.width = row.width;
    },
    //删除数据配置
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    delectReport(id) {
      //console.log("删除报表", id);
      this.$confirm(
        `将要删除id为:${id.id} 名称为:${id.name} 的报表吗？是否确定删除?`,
        "删除报表",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          let newMsg = {
            webMsgType: 1024,
            funCode: 2,
          };
          newMsg.data = { id: id.id };
          publishMsg(newMsg);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    exportButton() {
      if (this.body.length <= 0) {
        this.$message.warning("请查询数据后再导出！");
      } else {
        exportExcel(document.getElementById("myTable"), `实时报表.xlsx`);
      }
    },
    printJson() {
      this.initTableKey();
      this.$print(this.$refs.plxTable);
    },
    Perview(val) {
      //发送报表实时预览
      let newMsg1 = {
        webMsgType: 1024,
        funCode: 7,
      };
      newMsg1.data = { id: val.id };
      publishMsg(newMsg1);
      this.loadingShow = true;
      this.previewDialogVisible = true;
    },
    ConfigHear(val) {
      this.ConfigHearDialogVisible = true;
      let newMsg = {
        webMsgType: 1024,
        funCode: 3,
      };
      newMsg.data = { id: val.id };
      publishMsg(newMsg);
    },
    ConfigHearDialogClose() {},
    ConfigColsDialogClose() {},
    ConfigHearOk() {
      let newMsg = {
        webMsgType: 1024,
        funCode: 4,
      };
      let obj = { cols: this.dataList };
      newMsg.data = { ...obj, ...this.addReportFromData };
      // console.log(newMsg, "----------编辑表头");
      publishMsg(newMsg);
      this.ConfigHearDialogVisible = false;
    },
    ConfigColsOk() {},
    addHead() {
      this.addHaedDialogVisible = true;
    },
    addHaedDialogClose() {
      this.$nextTick(() => {
        this.$refs.addHaedRef.resetForm();
      });
    },
    editHaedDialogClose() {
      this.$refs.editHaedRef.resetForm();
    },
    editHaedOk() {
      let selectedlist = {};
      selectedlist.name = this.editHaedData.name;
      selectedlist.unit = this.editHaedData.unit;
      selectedlist.alian = this.editHaedData.alian;
      selectedlist.width = Number(this.editHaedData.width);
      selectedlist.type = this.editHaedData.type;
      this.$set(this.dataList, this.dataIndex, selectedlist);
      this.editHaedDialogVisible = false;
      // this.dataIdList = [];
    },
    addHaedOk() {
      this.addHaedData.width = Number(this.addHaedData.width);
      this.dataList.push(JSON.parse(JSON.stringify(this.addHaedData)));
      this.addHaedDialogVisible = false;
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.addcolsData.colsList.forEach((e) => {
            this.tableColsList.push(JSON.parse(JSON.stringify(e.value)));
          });
        }
      });
    },
    removeDomain(item) {
      var index = this.addcolsData.colsList.indexOf(item);
      if (index !== -1) {
        this.addcolsData.colsList.splice(index, 1);
      }
    },
    addCols() {
      this.addcolsData.colsList.push({ value: "", key: Date.now() });
    },
    //关闭预览窗口
    previewDataDialogClose() {
      this.header = [];
      // this.body = [];
    },
    //编辑报表列表
    editReportConfirm() {
      if (this.$refs.editReportForm.submitForm()) {
        let newMsg = {
          webMsgType: 1024,
          funCode: 1,
        };
        newMsg.data = this.editReportFromData;
        publishMsg(newMsg);
        this.editReportDialogVisible = false;
      }
    },
    //添加报表列表
    addReportConfirm() {
      if (this.$refs.addReportForm.submitForm()) {
        let newMsg = {
          webMsgType: 1024,
          funCode: 1,
        };
        newMsg.data = this.addReportFromData;
        publishMsg(newMsg);
        this.addReportDialogVisible = false;
      }
    },
    addReportDialogClose() {
      this.$refs.addReportForm.resetForm();
    },
    addDataEchoDialogClose() {
      this.$refs.addDataCongfigForm.resetFields();
    },
    addConfig() {
      this.addDataEchoDialogVisible = true;
    },
    // 导出数据表格
    exprotDataConfig(val) {
      let newMsg = {
        webMsgType: 1024,
        funCode: 5,
      };
      newMsg.data = { id: val.id };
      publishMsg(newMsg);
    },
    //导入表格
    async handleChange(ev, fileList, val) {
      let file = ev.raw;
      if (!file) return;
      const extension = file.name.substring(file.name.lastIndexOf(".") + 1);
      const fileType = ["xlsx", "xls"].some((item) => item === extension);
      if (!fileType) {
        this.$message.error("格式错误！请选择后缀是.xlsx, .xls 的文件");
        return;
      }
      let res = await getBase64(file);
      let newMsg = {
        webMsgType: 1024,
        funCode: 6,
      };
      newMsg.data = { id: val.id, base64_excel: res };
      publishMsg(newMsg);
    },
    disposePushData(ParamData, type) {
      if (this.getBodyData) {
        for (let k = 0; k < ParamData.length; k++) {
          //yc
          for (let i = 0; i < this.bodyConfigList.length; i++) {
            for (let j = 0; j < this.bodyConfigList[i].length; j++) {
              let cell = this.bodyConfigList[i][j];
              if (cell["type"] == type) {
                if (cell["id"] == ParamData[k]["id"]) {
                  let value = ParamData[k]["value"];
                  let oldValue = this.body[i][1 + j];
                  let nCol = 1 + j;
                  if (value != oldValue) {
                    console.log(444,this.$set)
                    this.$set(this.body[i], nCol, value);
                  }
                }
              }
            }
          }
        }
      }
    },
    onMessage(topic, msg) {
      // //console.log(topic, msg);
      switch (msg.webMsgType) {
        case 1024:
          switch (msg.funCode) {
            case 0:
              if (msg.retCode != 0 || !msg.data) {
                return this.$message.error(msg.retMsg);
              }
              this.TableList = msg.data;
              this.timeListloading = false;
              break;
            case 1:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0) {
                  this.$message.error(msg.retMsg);
                } else {
                  this.$message.success("添加报表成功!");
                }
              }
              break;
            case 2:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0) {
                  return this.$message.error(msg.retMsg);
                } else {
                  this.$message.success("删除报表成功!");
                }
              }
              break;
            case 3:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0) {
                  this.$message.error(msg.retMsg);
                } else {
                  if (msg.data) {
                    this.addReportFromData.id = msg.data.id;
                    this.addReportFromData.name = msg.data.name;
                    this.addReportFromData.type = msg.data.type;
                    this.dataList = msg.data.cols;
                  }
                }
              }
              break;
            case 4:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0) {
                  this.$message.error(msg.retMsg);
                } else {
                  this.$message.success("配置表头成功!");
                }
              }
              break;
            case 5:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0) {
                  this.$message.error(msg.retMsg);
                } else {
                  let base64Data = msg.data.base64_excel;
                  dataURLtoBlob(base64Data, "数据列表");
                }
              }
              break;
            case 6:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0) {
                  this.$message.error(msg.retMsg);
                } else {
                  this.$message.success("数据列表导入成功");
                }
              }
              break;
            case 7:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0 || !msg.data) {
                  this.$message.error(msg.retMsg);
                } else {
                  console.log(msg.data, "我7先收到");
                  this.body = msg.data.body;
                  this.header = msg.data.header;
                  this.header.forEach((e) => {
                    if (e.unit) {
                      e.name = e.name + "(" + e.unit + ")";
                    }
                  });
                  this.loadingShow = false;
                  let id = msg.data.id;
                  //发送报表配置预览
                  let newMsg2 = {
                    webMsgType: 1024,
                    funCode: 8,
                  };
                  newMsg2.data = { id: id };
                  publishMsg(newMsg2);
                }
                this.getBodyData = true;
              }
              break;
            case 8:
              if (checkSpecialId(msg)) {
                if (msg.retCode != 0 || !msg.data) {
                  this.$message.error(msg.retMsg);
                } else {
                  this.bodyConfigList = msg.data.body;
                }
              }
              break;
            default:
              break;
          }
          break;
        case 1009:
          switch (msg.funCode) {
            case 2:
              if (msg.retCode != 0 || !msg.data) {
                return this.$message.error(msg.retMsg);
              }
              this.disposePushData(msg.data, "yx");
              break;
            default:
              break;
          }
          break;
        case 1010:
          switch (msg.funCode) {
            case 2:
              if (msg.retCode != 0 || !msg.data) {
                return this.$message.error(msg.retMsg);
              }
              this.disposePushData(msg.data, "yc");
              break;
            default:
              break;
          }
          break;
        case 1011:
          switch (msg.funCode) {
            case 2:
              if (msg.retCode != 0 || !msg.data) {
                return this.$message.error(msg.retMsg);
              }
              this.disposePushData(msg.data, "ym");
              break;
            default:
              break;
          }
          break;
        case 1015:
          switch (msg.funCode) {
            case 4:
              if (msg.retCode != 0 || !msg.data) {
                return this.$message.error(msg.retMsg);
              }
              this.disposePushData(msg.data, "task");
              break;
            default:
              break;
          }
          break;
        default:
          break;
      }
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    //this.Onmessage();
    setMessageCallback(this.onMessage);
    //console.log("报表页面请求消息");
    publishMsg({
      webMsgType: 1024,
      funCode: 0,
    });
    this.timeListloading = true;
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {
    // setTimeout(() => {
    //   this.Onmessage();
    // }, 200);
  }, //生命周期 - 挂载之前
  destroyed() {
    removeMessageCallback(this.onMessage);
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-card__body {
  padding: 5px 5px 5px 5px;
}
::v-deep .el-dialog__body {
  padding: 10px 20px 20px 20px;
}
::v-deep .el-table__fixed-right {
  height: 100% !important;
}
::v-deep .tablehead-dialog .el-dialog__body {
  padding: 10px 20px;
}
</style>
